import axios from 'axios';
import Storage from './storage';
import { TOKEN_KEY } from './consts';
// 复杂项目中，接口可能有不同的基地址，所以要创建不同的axios实例对象
const request = axios.create({
    baseURL: 'http://ttapi.research.itcast.cn'
});
request.interceptors.request.use(config => {
    try {
        config.headers.Authorization = `Bearer ${Storage.getItemS(TOKEN_KEY).token}`;
    } catch (err) {
        console.log(err);
    }
    return config;
});

export default { request };
